package plug.LinkWordsPlugin;

import java.util.ArrayList;

import javax.swing.JPanel;

import plug.Introspection;

import Controller.MainController;
import Factories.FactoryDAO;
import Model.Correction;
import Model.Enonce;
import Model.Exercice;
import Model.Professeur;
import Model.Resultat;

public class LinkWords extends Exercice {

	@Override
	public double noter(Resultat r) {
		return 0;
	}

	@Override
	public int countError(Resultat r) {
		return 0;
	}

	@Override
	public JPanel getPanelEtud() {
		return null;
	}

	@Override
	public JPanel getPanelProf() {
		return new LinkWordsPanelProf();
	}

	@Override
	public ArrayList<Exercice> lister() {
		return null;
	}

	@Override
	public void corriger(Resultat r) {

		if (r.getReponses().equalsIgnoreCase(this.getCorrection().getContenu()))
		{
			r.setNote(20);
		}
		else r.setNote(0);

		r.creer();
	}

	@Override
	public void editer() {}

	@Override
	public JPanel consulter() {
		return new LinkWordsPanelProf();
	}

	@Override
	public void validerReponse(String rep) {}

	@Override
	public void creer() {}

	@Override
	public int countCorrect() {
		return 0;
	}

	@Override
	public void ajoutEnonce(Enonce e) {}

	@Override
	public void ajoutCorrection(Correction e) {}

	@Override
	public void supprimeEx() {}

	@Override
	public void construct(String nomExercice, Professeur pr) {

		this.exdao = FactoryDAO.getInstance(null).createExerciceDAO();
		type = nomExercice;
		auteur = pr.getIdCompte();
		nomPlugIn = exdao.nomPlugIn(nomExercice);

	}

	@Override
	public JPanel getPanel(MainController control) {
		return new Introspection(control,this);
	}
	
	public void creer(String texte) {

		Enonce e = new Enonce("");
		Correction co = new Correction(texte);
		this.setEnonce(e);
		this.setCorrection(co);
		this.exdao.create(this);

	}

	@Override
	public JPanel getRempliPanel(MainController control) {
		return new LinkWordsPanelEtud(control,this);
	}

}
